package com.hmsm.sys.service;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.hmsm.server.util.QueryResult;
import com.hmsm.sys.bean.LocalDept;
import com.hmsm.sys.bean.LocalRole;
import com.hmsm.sys.bean.LocalUser;
import com.lzyyj.common.Page;
import com.lzyyj.gmis.base.model.Purview;

@SuppressWarnings("rawtypes")
public interface IRoleInfoService<T extends LocalRole, PK extends Serializable, U extends LocalUser> {

	public boolean haveRight(String funcCode, U currentUser) throws Exception;
	
	public boolean deleteById(Integer roleId, U currentUser) throws Exception;
	
	public void resetFuncAndRoles() throws Exception;
	
	public void clearRoleFunc(int roleId);
	
	public void saveRoleFuncs(int roleId, List<Integer> funcIds, U currentUser) throws Exception;
	
	public T getById(PK id);
	
	public QueryResult<T> manage(Integer orgId, String name, String nowpage, String maxpage, U currentUser) throws Exception;
	
	public T save(T entity) throws Exception;
	
	public T update(T entity) throws Exception;

	public List<LocalDept> getManageOrgList(U currentUser) throws Exception;

	public Map<Integer, LocalDept> getManagedOrgs(LocalUser currentUser) throws Exception;

	public List<T> getRoleInfoAll();
	
	public void loadUserRoles(U currentUser);
	
	public void loadUserRoles(U currentUser, Map<Integer,T> roleMap);
	
	public LinkedHashMap<Map<String, Object>,List<Map<String, Object>>> getMenu();
	
	public String getRoleFuncArray(int roleId);

	public List<U> getRoleUsers(Integer roleId, Set<Integer> managedOrgIds);

	public void bindUserRoleRelation(Integer userId, Integer roleId) throws Exception;

	public void unbindUserRoleRelation(Integer userId, Integer roleId) throws Exception;

	public boolean haveRightRange(U currentUser, String funcCode, String[] rangeCodes);

	public List<T> getAllRoleInfo();

	/**
	 * 获得拥有指定功能模块下指定功能权限的用户id集合
	 */
	public Set<Integer> getUserIdsByFuncs(String mainFuncCode, String... funcs) throws Exception;

	public Page<Purview> purviewManage(Page<Purview> page, U sessionUser);

	public Purview purviewSave(Purview item, U sessionUser);

	public void purviewDel(Integer id, U sessionUser);

	/**
	 * 是否是系统管理员角色
	 * @param roleInfo
	 * @return
	 */
	public boolean isAdminRole(T roleInfo);

	public boolean haveManageRight(T roleInfo, U currentUser);

	public boolean haveUserAuthRight(T roleInfo, U currentUser);

	public List<LocalRole> getDefaultRolesByOrgId(Integer orgId);
	
}
